const util = require('../../../utils/util.js');
var user = require('../../../services/user.js');
var app = getApp();
Page({
  data: {
    isLogin: false,
    headerSrc: '',
    userInfo: '',
    teacherlist:[]
  },
  onShow: function () {
    let token = wx.getStorageSync('token')
    console.log(token)
    if (token) {
      this.setData({
        isLogin: true
      })
      this.getlist()
    } else{
      wx.navigateTo({
        url: '../../login/login',
      })
    }
  },
  getlist: function () {
    let that = this;
    util.request('school/geteacherlist').then(function (res) {
      console.log(res.data);
      if (res.errno === 0) {
        that.setData({
          teacherlist:res.data
        })
      }
    });
  },
  toteacher(e){
    console.log(e.currentTarget.dataset.id)
    wx.navigateTo({
      url: '/pages/teacherdetails/teacherdetails?id=' + e.currentTarget.dataset.id,
    })
  },
  switchIndex(){
    wx.switchTab({
      url: '/pages/index/index'
    })
  }
})